local skel = fk.CreateSkill {
  name = "lb__jumu",
  tags = { Skill.Compulsory }
}

Fk:loadTranslationTable {
  ["lb__jumu"] = "聚目",
  --[":lb__jumu"] = "<b>锁定技</b>，当你仅弃置一张牌后，本回合所有角色不能使用与之花色相同的牌。",
  [":lb__jumu"] = "<b>锁定技</b>，当你仅弃置一张牌后，本回合所有角色不能使用与之花色相同的牌，且你使用与之不同花色的牌无距离和次数限制。",

  ["@lb__jumu-turn"] = "聚目",

  ["$lb__jumu1"] = "绝佳配合。",
  ["$lb__jumu2"] = "考验默契的时候。",
}

skel:addEffect(fk.AfterCardsMove, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(skel.name) then return false end
    for _, move in ipairs(data) do
      if move.from and move.proposer and move.from == player and move.proposer == player
          and move.toArea == Card.DiscardPile and move.moveReason == fk.ReasonDiscard and #move.moveInfo == 1 then
        local card = Fk:getCardById(move.moveInfo[1].cardId)
        event:setCostData(self, { suit = card:getSuitString(true) })
        return card.suit ~= Card.NoSuit and not table.contains(player:getTableMark("@lb__jumu-turn"), card:getSuitString(true))
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local suit = event:getCostData(self).suit
    room:doIndicate(player, room:getAllPlayers())
    room:addTableMark(player, "@lb__jumu-turn", suit)
  end,
})

skel:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    local list = {}
    for _, to in ipairs(Fk:currentRoom().alive_players) do
      if to:hasSkill(skel.name) then
        table.insertTableIfNeed(list, to:getTableMark("@lb__jumu-turn"))
      end
    end
    return table.contains(list, card:getSuitString(true))
  end,
})

local jumu_spec = function (player, card)
  local list = player:getTableMark("@lb__jumu-turn")
  if #list > 0 and player:hasSkill(skel.name) and card then
    return not table.contains(list, card:getSuitString(true))
  end
end

skel:addEffect("targetmod", {
  bypass_times = function (self, player, skill, scope, card, to)
    return jumu_spec(player, card)
  end,
  bypass_distances = function (self, player, skill, card, to)
    return jumu_spec(player, card)
  end,
})

return skel
